<!DOCTYPE html>
<html class="x-admin-sm">
    <head>
        <meta charset="UTF-8">
        <title>新建咨询单</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
        <link rel="stylesheet" href="/static/css/font.css">
        <link rel="stylesheet" href="/static/css/xadmin.css">
		<link rel="stylesheet" href="/static/css/table.css">
        <script src="/static/lib/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="/static/js/xadmin.js"></script>
        <script type="text/javascript" src="/static/js/jquery.min.js"></script>
		<script type="text/javascript" src="/static/js/jquery.form.js"></script>
        <!--[if lt IE 9]>
          <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
          <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
    </head>
    <body>
        <div class="x-nav">
          <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
            <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
        </div>
        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
						<form class="layui-form" id="signupForm" action="{:url('shop/activity/mjaddactiv')}" method="post">
                        <div class="layui-card-body">
							<div class="layui-tab layui-tab-card" style="margin-bottom:15px;">
							  <ul class="order_table">
								<li>活动信息</li>
							  </ul>
							  <div class="layui-tab-content">
								 <div class="layui-form-item">
									  <label class="layui-form-label">活动名称</label>
									  <div class="layui-input-inline">
										  <input type="text" name="act_name" class="layui-input" placeholder="请输入活动名称">
									  </div>
								  </div>
								  <div class="layui-form-item">
									  <label class="layui-form-label">活动有效期</label>
									  <div class="layui-input-inline">
										  <input type="text" name="start" id="start" class="layui-input" placeholder="请选择开始时间">
									  </div>
									  <div class="layui-input-inline">
										  <input type="text" name="end" id="end" class="layui-input" placeholder="请选择结束时间">
									  </div>
								  </div>
                                  {if condition="$ty eq '0'"}
								  <div class="layui-form-item">
									<div class="layui-inline">
									  <label class="layui-form-label">满足金额（元）</label>
									  <div class="layui-input-inline">
										<input type="text" name="mz_money" class="layui-input" placeholder="请输入满足金额">
									  </div>
									</div>
									<div class="layui-inline">
									  <label class="layui-form-label">优惠金额（元）</label>
									  <div class="layui-input-inline">
										<input type="text" name="yh_money" class="layui-input" placeholder="请输入优惠金额">
									  </div>
									</div>
								 </div>
                                 {elseif condition="$ty eq '1'" /}
                                 <div class="layui-form-item">
									<div class="layui-inline">
									  <label class="layui-form-label">折扣</label>
									  <div class="layui-input-inline">
										<input type="text" name="discount" class="layui-input" placeholder="请输入折扣%">
									  </div>
									</div>
									<div class="layui-inline">
									  <label class="layui-form-label">满足数量</label>
									  <div class="layui-input-inline">
										<input type="text" name="number" class="layui-input" placeholder="请输入满足数量">
									  </div>
									</div>
								 </div>
                                 <div class="layui-form-item">
									  <label class="layui-form-label">活动商品</label>
									  <div class="layui-input-inline">
                                          <input type="hidden" name="zs_goods" id="gid"/>
										  <input type="text" id="gname" readonly="readonly" onclick="xadmin.open('选择商品','{:url('shop/activity/activitygoods')}',1000,600)" class="layui-input" placeholder="请选择活动商品" style="width:500px;cursor:pointer;">
									  </div>
								  </div>
                                 {elseif condition="$ty eq '2'" /}
                                 <div class="layui-form-item">
									  <label class="layui-form-label">满足金额（元）</label>
									  <div class="layui-input-inline">
										<input type="text" name="mz_money" class="layui-input" placeholder="请输入满足金额">
									  </div>
								  </div>
                                  <div class="layui-form-item">
									  <label class="layui-form-label">活动商品</label>
									  <div class="layui-input-inline">
                                          <input type="hidden" name="zs_goods" id="gid"/>
										  <input type="text" id="gname" readonly="readonly" onclick="xadmin.open('选择商品','{:url('shop/activity/activitygoods')}',1000,600)" class="layui-input" placeholder="请选择活动商品" style="width:500px;cursor:pointer;">
									  </div>
								  </div>
                                 {else /}
                                 <div class="layui-form-item">
									  <label class="layui-form-label">折扣</label>
									  <div class="layui-input-inline">
										<input type="text" name="discount" class="layui-input" placeholder="请输入折扣%">
									  </div>
								  </div>
                                  <div class="layui-form-item">
									  <label class="layui-form-label">活动商品</label>
									  <div class="layui-input-inline">
										  <input type="hidden" name="zs_goods" id="gid"/>
                                          <ul id="gname">
                                               <li><input type="text" readonly="readonly" class="layui-input" style="width:500px;"></li>
                                          </ul>
                                          <button type="button" class="layui-btn" onclick="xadmin.open('选择商品','{:url('shop/activity/activitygoods3')}',1000,600)">选择商品</button>
                                      </div>
								  </div>
                                 {/if}
								 <div class="layui-form-item">
									  <label for="L_repass" class="layui-form-label">
                                        <input type="hidden" name="act_type" value="{$ty}"/>
									  </label>
									  <button  class="layui-btn" lay-filter="add" lay-submit="">增加</button>
								  </div>
							  </div>
							</div>
                        </div>
						</form>
                    </div>
                </div>
            </div>
        </div> 
		<script>
        var flag = true;
        layui.use(['form', 'layer', 'laydate'],
            function() {
                $ = layui.jquery;
                var form = layui.form,
                layer = layui.layer;
				var laydate = layui.laydate;

                 //监听提交
                form.on('submit(add)',
                function(data) {
                    if(flag)
                    {
                        flag = false;
                        $("#signupForm").ajaxSubmit(function (message) {
                             if(message.code == 10001)
                             {
                                layer.msg("执行成功", {
                                    icon: 6
                                },
                                function() {
                                    //关闭当前frame
                                    xadmin.close();
                                    // 可以对父窗口进行刷新 
                                    xadmin.father_reload();
                                });
                             }else{
                                layer.msg(message.msg, {
                                    icon: 5
                                },
                                function() {
                                    //关闭当前frame
                                    xadmin.close();
                                    // 可以对父窗口进行刷新 
                                    xadmin.father_reload();
                                });
                             }
                        });
                    }else{
                        layer.msg('正在提交。。。', {icon: 6});
                    }
                    return false;
                });
				//日期范围
			  testObj = {
                init: function(){
                    this.bindEvent();
                },
                bindEvent: function(){
                    // 开始时间
                    var start = laydate.render({
                        elem: '#start',
                        trigger: 'click',
                        btns: ['clear', 'confirm'],
                        // showBottom: false,
                        done: function (value, date) {
                            end.config.min = {
                                year: date.year,
                                month: date.month - 1,
                                date: date.date,
                                hours: date.hours,
                                minutes: date.minutes,
                                seconds: date.seconds
                            };
                            // 作为 结束选择 的 开始时间
                            end.config.value = value;
                        }
                    });
                    // 结束时间
                    var end = laydate.render({
                        // 绑定元素
                        elem: '#end',
                        //  触发方式
                        trigger: 'click',
                        // 底部按钮
                        btns: ['clear', 'confirm'],
                        // showBottom: false,
                        // 选择完成回调
                        done: function (value, date) {
                            start.config.max = {
                                year: date.year,
                                month: date.month - 1,
                                date: date.date,
                                hours: date.hours,
                                minutes: date.minutes,
                                seconds: date.seconds
                            };
                            start.config.value = value;
                        }
                    });
                    laydate.render(start);
                    laydate.render(end);
                }
            }
            testObj.init();
            
            var data_sure = [];
            window.GetValue = function(obj)
            {
                var gids = '';
                var str = '';
                for (i in obj) {
                    gids += obj[i]['goods_id'] + ',';
                    str += '<li><input type="text" class="layui-input" style="width:500px;" value="'+obj[i]['goods_name']+'"></li>';
                }
                gids = gids.substr(0, gids.length - 1);
                
                data_sure = obj;
                
                $('#gid').val(gids);
                $('#gname').html(str);
            }
            window.open_data = function()
              {
                  return data_sure;
              }
            });
            </script>
    </body>
</html>